package com.thirteenClassicsServer.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import com.github.pagehelper.Page;
import com.thirteenClassics.annotation.AutoFill;
import com.thirteenClassics.dto.MarkEntryDTO;
import com.thirteenClassics.entity.Dictionary;
import com.thirteenClassics.enumeration.OperationType;

@Mapper
public interface DictionaryMapper {

    Page<Dictionary> pageQuery(MarkEntryDTO markEntryDTO);

    //新增词义
    void insertBatch(List<Dictionary> dictionaries);

    @Insert("insert into dictionary (book_name, word_s1, word_s2, word_jdb, sentence_id, word_ch, word_type, "
            + "create_time, create_user, update_user, update_time) values "
            + "(#{bookName}, #{wordS1}, #{wordS2}, #{wordJdb}, #{sentenceId}, #{wordCh}, #{wordType}, #{createTime}, "
            + "#{createUser}, #{updateUser}, #{updateTime})")
    @AutoFill(OperationType.INSERT)
    void insert(Dictionary dictionary);


    @Select("select * from dictionary where sentence_id=#{sentenceId} and book_name=#{bookName}")
    List<Dictionary> selectBySentenceId(Long sentenceId, String bookName);

    @Delete("DELETE from dictionary where sentence_id=#{sentenceId} and book_name=#{bookName}")
    void deleteBySentenceId(Long sentenceId, String bookName);

}
